import React from 'react';

import BaseAction from '../common/BaseAction';
import Constants from '../../common/Constants';
import ResponseConstants from '../../common/ResponseConstants';

export default class LoginSendVerifyAction extends BaseAction {
  constructor() {
    super();

    this.moduleType = Constants.MODULE_TYPE.LOGIN;
    this.name = "LoginSendVerifyAction";
  }

  call(caller, data) {
    this._baseCall(caller, data);
    this.caller.setState({
      viewStatus: 4,
    })
  }

  finish(data, isSucceed, response, callback) {
    let detail = "";
    if(response.status == ResponseConstants.status_deal_success) {
      detail = "验证成功";
      callback(data);
    }
    else if (response.status == ResponseConstants.status_unauthorized) {
      detail = data.detail;
    }
    else if (response.status == ResponseConstants.status_server_error) {
      detail = "服务器出错";
    }
    else {
      detail = "未知错误";
    }
    this.caller.setState({
      viewStatus: response.status,
      statusText: detail,
    })
  }
}
